package org.linlinjava.litemall.admin.web2.auth.resp;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.linlinjava.litemall.core.util.DateTimeUtil;
import org.linlinjava.litemall.db.domain.LitemallAdmin;
import org.linlinjava.litemall.db.domain.TShop;
import org.linlinjava.litemall.db.enumeration.Const;
import org.linlinjava.litemall.db.util.Str;

/**
 * 管理员列表
 */
@ApiModel
public class AResp {

    @ApiModelProperty("id")
    private Integer id;
    @ApiModelProperty("登录账号")
    private String username;
    @ApiModelProperty("用户组")
    private String roleName;
    @ApiModelProperty("真实名字")
    private String realName;
    @ApiModelProperty("微信")
    private String wx;
    @ApiModelProperty("联系电话")
    private String phone;
    @ApiModelProperty("最近一次登录时间")
    private String lastLoginTime;
    @ApiModelProperty("商铺名称")
    private String shopName;


    public AResp() {
    }

    public AResp(LitemallAdmin admin) {
        this.id = admin.getId();
        this.username = admin.getUsername();
        if (admin.getLastLoginTime() != null)
            this.lastLoginTime = admin.getLastLoginTime().format(DateTimeUtil.format);
        this.wx = admin.getWx();
        this.realName = admin.getRealName();
        StringBuilder sb = Str.sb();
        if (admin.getGoodsManager()) {  //是否商品管理员
            sb.append("商品管理员");
            sb.append("、");
        }
        if (admin.getSendManager()) {  //是否商品派送员
            sb.append("商品派送员");
        }
        roleName = sb.toString();
        this.phone = admin.getPhone();
    }

    public void pushShop(TShop shop) {
        if (shop != null) {
            this.shopName = shop.getShopName();
            roleName = Const.Identity.value(shop.getIdentity()) + "、" + roleName;
        }
    }


    public String getLastLoginTime() {
        return lastLoginTime;
    }

    public void setLastLoginTime(String lastLoginTime) {
        this.lastLoginTime = lastLoginTime;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public String getWx() {
        return wx;
    }

    public void setWx(String wx) {
        this.wx = wx;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getShopName() {
        return shopName;
    }

    public void setShopName(String shopName) {
        this.shopName = shopName;
    }
}
